/**
 * 
 */
package fr.univnantes.lina.mlnlp.connectors.svmlight;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import fr.univnantes.lina.mlnlp.models.ml.Feature;
import fr.univnantes.lina.mlnlp.models.ml.Instance;

/**
 * @author hernandez
 *
 */
public class SVMLightInstance extends Instance {

		
		
		/**
		 * SVMLight format [2,3]
<target> <feature>:<value> <feature>:<value> ... <feature>:<value> # <info>
		[2] http://mallet.cs.umass.edu/import.php
		[3] http://svmlight.joachims.org/
		 * @return
		 */
		public String toString() {
			String line = getLabel();
			Iterator<Feature> featureIterator = getFeatureList().iterator();
			while (featureIterator.hasNext()) {
				Feature feature = featureIterator.next();
				line = line + " " + feature.getName() +":"+ String.valueOf(feature.getValue());
			}
			return line;
		}
		
		
}
